$(function(){
    var news = new News();
    news.init().init();
});


function News(){
    this.init = function(){
        return NEWS;
    };
    
    var NEWS = {
        init : function(){
            NEWS.listeners.bindEvents();
        },
        listeners : {
            bindEvents : function(){
                $.util.foreachFunction(this, [ "bindEvents" ]);
            },
            bindDelete : function(){
                $("#table_agents_manager a.c_news_delete").click(
                    function(){
                        if(confirm('是否确定删除？')){
                            $.util.initHiddenFormSubmit($('#frm_news_manager_hidden'),SYSTEM_DATA.contextPath + '/Message/delete.shtml',  [{
                                'name' : 'id',
                                'value' : $(this).attr('n_id')
                                }]);
                        }
                    });
            },
            bindFolatRed : function(){
                $("#table_agents_manager :checkbox").click(function(){
                    var $this = $(this);
                    var float_red = 0;
                    var text = '已取消飘红';
                    if('checked' == $this.attr('checked')){
                        float_red = 1;
                        text = '已添加飘红';
                    }
                    
                    $.post(SYSTEM_DATA.contextPath + '/Message/floatRed.shtml', {
                        'id' : $this.attr('m_id'), 
                        'float_red' : float_red
                    }, function(jsonResult){
                        if(0 == jsonResult.status){
                            alert(jsonResult.info);
                            return;
                        }
                        
                        alert(text);
                    }, 'json');
                });
            }
        },
        funs : {}
    };
}